<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // url => 资源 接口
        // https://api.github.com/users/wesbos
        // fetch('https://api.github.com/users/wesbos')
        //     .then(data=>data.json())
        //     .then(data=>{
        //         console.log(data);
        //     })
        (async function(){
            // console.log(await fetch('https://api.github.com/users/wesbos'));
            // await 后 promise 执行的 resolve 把结果给左边
            // const response=await fetch('https://api.github.com/users/wesbos');
            // const data=await response.json(); //     response.json() Promise对象
            // console.log(data);
            // const response2=await fetch('https://api.github.com/users/shunwuyu');
            // const data2=await response2.json(); //     response.json() Promise对象
            // console.log(data2);
            const p1=fetch('https://api.github.com/users/wesbos');
            const p2=fetch('https://api.github.com/users/shunwuyu');
            // 多个promise异步任务时
            // Promise.all([p1,p2])    //static 方法 并发执行
            // Promise.all(); Promise 对象
            console.log(Object.prototype.toString.call(Promise.all()));
            const res=await Promise.all([p1,p2]);
            // console.log(res); 
            // res.map
            const [wes,shunwu] =await Promise.all(res.map(r =>r.json()));

            console.log(wes,shunwu  );
        })();
    </script>
</body>
</html>